package org.andao.commons.lucene.bean;

/**
 * lucene查询条件bean
 * 
 * @author Seewo Software - Vick.liu (liuguanglin@cvte.cn)
 * 
 */
public class ConditionBean {

	/**
	 * 关键字（用户输入的关键字）
	 */
	private String keywords;

	/**
	 * 要匹配的字段集合
	 */
	private String[] matchingIndex;

	/**
	 * 是否是filter，如果是filter，则该condition使用过滤方式，如果不是filter，则该condition使用模糊匹配的形式，
	 * 默认是filter
	 */
	private boolean isFilter = true;

	/**
	 * 构造filter，
	 * <ul>
	 * <li>匹配 sQuery.addFilterQuery("matchingIndex","keywords");</li>
	 * </ul>
	 * 
	 * @param filterValue
	 *            关键字（用户输入的关键字）
	 * @param filterKey
	 *            要匹配的字段
	 */
	public ConditionBean(String filterValue, String filterKey) {
		this.keywords = filterValue;
		this.matchingIndex = new String[] { filterKey };
		this.isFilter = true;
	}

	/**
	 * 构造query
	 * <ul>
	 * <li>匹配 sQuery.setQuery(
	 * "matchingIndex[0]:keywords or matchingIndex[1...n]:keywords");</li>
	 * </ul>
	 * 
	 * @param keywords
	 *            关键字（用户输入的关键字）
	 * @param matchingIndex
	 *            要匹配的字段集合
	 */
	public ConditionBean(String keywords, String[] matchingIndex) {
		this.keywords = keywords;
		this.matchingIndex = matchingIndex;
		this.isFilter = false;
	}

	// --------setter and getter ----------//
	public String getKeywords() {
		return keywords;
	}

	public void setKeywords(String keywords) {
		this.keywords = keywords;
	}

	public String[] getMatchingIndex() {
		return matchingIndex;
	}

	public void setMatchingIndex(String[] matchingIndex) {
		this.matchingIndex = matchingIndex;
	}

	public boolean isFilter() {
		return isFilter;
	}

	public void setFilter(boolean isFilter) {
		this.isFilter = isFilter;
	}

}
